﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PQ.Helper;
using PQ.Enum;

namespace PQ.Model
{
    [Serializable]
    public class UserEntity
    {
        public UserEntity()
        {
            this.cookie = new System.Net.CookieContainer();
        }
        //在多处用到的常量
        public readonly String appid = "15000101";

        /// <summary>
        /// 收到好友 消息事件
        /// </summary>
        public event Action<MessageModel> OnFriendMessageEvent;


        /// <summary>
        /// QQ号
        /// </summary>
        public string Uin { get; set; }
        private String userName;

        public String UserName
        {
            get { return userName; }
            set { userName = value; }
        }

        private string g_tk;

        /// <summary>
        /// 获取g_tk参数，
        /// </summary>
        //public string G_tk
        //{
        //    //get { return QzoneUtils.GetGtkByCookieSkey(Cookie).ToString(); }
        //}

        private String password;

        public String Password
        {
            get 
            {
                password= Utils.getMd5Hash2(Utils.getMd5Hash(Ppwwdd).ToUpper() +
                        this.VerifyCode.ToUpper()).ToUpper();
                return password;
            }
            set 
            {
                Ppwwdd = value;
                password = value;
            }
        }
        private string ppwwdd;
        /// <summary>
        /// 密码..
        /// 有 前缀和后缀
        /// </summary>
        public string Ppwwdd
        {
            get
            {
                return ppwwdd.Substring(18);
            }
            set
            {
                ppwwdd = RandData.GetInstance().GetRandStr(18) + value;
            }
        }

        private String verifyCode;
        /// <summary>
        /// 验证码
        /// </summary>
        public String VerifyCode
        {
            get
            {
                if (verifyCode == null)
                {
                    return string.Empty;
                }
                else
                {
                    return verifyCode;
                }
            }
            set
            {
                verifyCode = value;
            }
        }

        /// <summary>
        /// 48位验证码算子
        /// </summary>
        private String verifyCode32;

        public String VerifyCode32
        {
            get { return verifyCode32; }
            set { verifyCode32 = value; }
        }

        private bool isOpenQzone;

        public bool IsOpenQzone
        {
            get { return isOpenQzone; }
            set { isOpenQzone = value; }
        }

        private LoginStatus status;

        /// <summary>
        /// 状态
        /// </summary>
        public LoginStatus Status
        {
            get { return status; }
            set { status = value; }
        }

        private System.Net.CookieContainer cookie;

        public System.Net.CookieContainer Cookie
        {
            get { return cookie; }
            set { cookie = value; }
        }

        private string nickName;
        /// <summary>
        /// 昵称
        /// </summary>
        public string NickName
        {
            get { return nickName; }
            set { nickName = value; }
        }

        private string mPhone;

        /// <summary>
        /// 手机
        /// </summary>
        public string MPhone
        {
            get { return mPhone; }
            set { mPhone = value; }
        }

        private string telePhone;

        /// <summary>
        /// 电话
        /// </summary>
        public string TelePhone
        {
            get { return telePhone; }
            set { telePhone = value; }
        }

        private int sex;

        /// <summary>
        /// 性别1男2女
        /// </summary>
        public int Sex
        {
            get { return sex; }
            set { sex = value; }
        }

        private int age;

        /// <summary>
        /// 年龄
        /// </summary>
        public int Age
        {
            get { return age; }
            set { age = value; }
        }

        private string email;

        /// <summary>
        /// 邮箱
        /// </summary>
        public string Email
        {
            get { return email; }
            set { email = value; }
        }

        private string job;
        /// <summary>
        /// 职业
        /// </summary>
        public string Job
        {
            get { return job; }
            set { job = value; }
        }

        private string school;
        /// <summary>
        /// 学校
        /// </summary>
        public string School
        {
            get { return school; }
            set { school = value; }
        }

        private string homeUrl;
        /// <summary>
        /// 主页
        /// </summary>
        public string HomeUrl
        {
            get { return homeUrl; }
            set { homeUrl = value; }
        }

        private string personalElucidation;
        /// <summary>
        /// 个人说明
        /// </summary>
        public string PersonalElucidation
        {
            get { return personalElucidation; }
            set { personalElucidation = value; }
        }

        public string Skey
        {
            get
            {
                return WebQQUtil.GetGtkByCookieSkey("skey", Cookie);
            }
        }

        public string ptwebqq
        {
            get
            {
                return WebQQUtil.GetGtkByCookieSkey("ptwebqq", Cookie);
            }
        }

        private string key;

        /// <summary>
        /// vfwebqq
        /// </summary>
        public string Key
        {
            get { return key; }
            set { key = value; }
        }

        private string psessionid;

        public string Psessionid
        {
            get { return psessionid; }
            set { psessionid = value; }
        }

        private string clientId;

        public string ClientId
        {
            get { return clientId; }
            set { clientId = value; }
        }

        private Dictionary<int, string> categories;
        /// <summary>
        /// 分组 种类(我的好友，陌生人)
        /// </summary>
        public Dictionary<int, string> Categories
        {
            get { return categories; }
            set { categories = value; }
        }

        private Dictionary<string, FriendModel> friendsDic;
        /// <summary>
        /// 我的好友
        /// </summary>
        public Dictionary<string, FriendModel> FriendsDic
        {
            get { return friendsDic; }
            set { friendsDic = value; }
        }

        private Dictionary<string, GroupModel> groupDic;

        public Dictionary<string, GroupModel> GroupDicd
        {
            get { return groupDic; }
            set { groupDic = value; }
        }
    }
}
